package hczc.longcai.com.hccrowdfunding.home.fourth_mine.activities;

import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import hczc.longcai.com.hccrowdfunding.R;
import hczc.longcai.com.hccrowdfunding.activity.BaseActivity;
import hczc.longcai.com.hccrowdfunding.application.BaseApplication;
import hczc.longcai.com.hccrowdfunding.beans.UserInfo;
import hczc.longcai.com.hccrowdfunding.home.fourth_mine.fragments.Mine_Data_Head_Fragment;
import hczc.longcai.com.hccrowdfunding.home.fourth_mine.fragments.Mine_Data_Normal_Fragment;

public class MineDataActivity extends BaseActivity implements View.OnClickListener {

    /**
     * 用户头像
     */
    private String head;
    /**
     * 用户昵称
     */
    private String name;
    /**
     * 用户手机号
     */
    private String phone;
    private Mine_Data_Head_Fragment mine_data_head_fragment;
    private Mine_Data_Normal_Fragment mine_data_normal_fragment;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mine_data);

        initDatas();

        initFragments();

        initViews();

    }

    private void initFragments() {
        mine_data_head_fragment = new Mine_Data_Head_Fragment();
        Bundle c_head = new Bundle();
        c_head.putString("head",head);
        mine_data_head_fragment.setArguments(c_head);
        mine_data_normal_fragment = new Mine_Data_Normal_Fragment();
        Bundle c_normal = new Bundle();
        c_normal.putString("name",name);
        c_normal.putSerializable("phone",phone);
        mine_data_normal_fragment.setArguments(c_normal);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.mine_fargment_head,mine_data_head_fragment);
        transaction.replace(R.id.mine_fragment_normal,mine_data_normal_fragment);
        transaction.commit();
    }

    private void initDatas() {
        UserInfo userinfo = (UserInfo) getIntent().getExtras().getSerializable("userinfo");
        head = userinfo.getHead();
        name = userinfo.getName();
        phone = userinfo.getPhone();

    }

    private void initViews() {
        findViewById(R.id.head_back).setOnClickListener(this);
        ((TextView) findViewById(R.id.head_title)).setText("个人资料");
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id){
            case R.id.head_back:
                finish();
                break;


        }
    }
}
